package me.jzn.alib.utils;

import android.content.Context;

import androidx.core.content.ContextCompat;

import java.util.concurrent.Executor;

public class ExecutorUtil {
    private static Executor sInstanceExecutor;

    //一般不常用
    public static final Executor getMainExecutor(Context ctx) {
        return ContextCompat.getMainExecutor(ctx);
    }
    //在room打印sql和strictmode打印日志的时候需要这个，一般如果换成其他的，会导致sql参数混乱
    public static final Executor getSimpleExecutor() {
        if (sInstanceExecutor == null) {
            sInstanceExecutor = new Executor() {
                @Override
                public void execute(Runnable command) {
                    command.run();
                }
            };
        }
        return sInstanceExecutor;
    }
}
